﻿@model EntryViewModel

<div class="entry">
	<div class="entryTitle">
		@if (this.Model.PreviewEdit)
		{	
			<h1 class="previewLink">@this.Model.Title</h1>				
		}
		else
		{
			<h1><a title="@this.Model.Title" href="@this.Url.Action("View", new { entryId = this.Model.Id })">@this.Model.Title</a></h1>
		}
		<div class="entryControlButtons">
			<span class="currentRank">@this.Model.Rank |</span>
				@if (this.Model.PreviewEdit)
				{
					<span class="previewLink">+</span>
					<span class="previewLink">-</span>
				}
				else
				{
					using (this.Html.BeginForm(new { action = "Rank" }))
					{
						<input type="hidden" value="@this.Model.Id" name="entryId" />
						<input type="hidden" value="@this.Html.GetActionName()" name="backAction" />
						<button name="action" title="@Resources.RankGood" type="submit" class="rankButton entryRank" value="+">+</button>
						<button name="action" title="@Resources.RankBad" type="submit" class="rankButton entryRank" value="-">-</button>
					}
					if (this.Model.IsLogged)
					{
						using (this.Html.BeginForm(new { action = "Manage" }))
						{
							<input type="hidden" value="@this.Model.Id" name="entryId" />
							<input type="hidden" value="@this.Html.GetActionName()" name="backAction" />
							if (this.Model.IsPublished)
							{ 
								<button name="action" type="submit" value="unpublish" title="@Resources.UnpublishEntry" class="linkButton">@Resources.Unpublish</button>
							}
							else
							{		
								<button name="action" type="submit" value="publish" title="@Resources.PublishEntry" class="linkButton">@Resources.Publish</button>
							}
							<a href="@this.Url.Action("Edit", new { viewType = this.Model.ViewType, entryId = this.Model.Id })" title="@Resources.EditEntry">@Resources.Edit</a>
							<button name="action" type="submit" value="delete" title="@Resources.DeleteComment" class="linkButton">@Resources.Delete</button>
						}
					}
				}
		</div>
	</div>
	<div class="entryProperties">
		@this.Model.CreatedOn 
		@if (this.Model.DisplayComments)
		{
			<text>|</text> <a href="@this.Url.Action("View", new { entryId = this.Model.Id })#comments" title="@Resources.EntryComments">@Resources.Comments (<span class="commentsCount">@this.Model.Comments.Count</span>)</a>
		}
		@if (this.Model.Tags.Count > 0)
		{
			<text>|</text> @Resources.Tags 
			<text>:</text>
			foreach (TagViewModel tagModel in this.Model.Tags)
			{
				@this.Html.ActionLink(tagModel.Name, "List", new { controller = "Entries", viewType = this.Model.ViewType, pageNumber = 1, tag = tagModel.Code });
			}
		}
	</div>
	<div class="entryContent">
		@foreach (EntryElementViewModel elementModel in this.Model.Elements)
		{
			this.Html.RenderPartial(elementModel.ViewViewName, elementModel);
		}
	</div>
	
	@if (this.Model.LastUpdatedOn.HasValue)
	{ 
		<div class="entryDateModified">
			@Resources.LastUpdated @this.Model.LastUpdatedOn
		</div>
	}
</div>